home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 4.6 KB | 173 lines | [TEXT/MPS ] |
- /*
- File: BLJOCEUTilities.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __BLJOCEUTILITIES__
- #include "BLJOCEUtilities.h"
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
- #ifndef __GESTALTEQU__
- #include <GestaltEqu.h>
- #endif
-
- /***********************************|****************************************/
-
- #pragma segment BLJOCEUtilities
-
- /***********************************|****************************************/
-
- inline min(int a, int b) { return a < b ? a : b; }
-
- /***********************************|****************************************/
-
- Boolean CreateRString (RString& r, char *data, short length, short maxSize, short charSet)
- {
- r.charSet = charSet;
- r.dataLength = min ( (int) length, (int) maxSize);
-
- if (r.dataLength > 0)
- {
- BlockMove ((Ptr) data, (Ptr) &r.body, r.dataLength);
- return true;
- }
-
- return false;
- }
-
- /***********************************|****************************************/
-
- RStringPtr NewRStringPtr(const char* data, short length, short maxSize, short charSet)
- {
- RStringPtr r = (RStringPtr) FAILNewPtr(sizeof(ProtoRString) + length);
- r->charSet = charSet;
- r->dataLength = min( (int) length, (int) maxSize);
- BlockMove( data, &r->body, r->dataLength);
- return r;
- }
-
- /***********************************|****************************************/
-
- RStringPtr NewRStringPtrCopy(const RStringPtr r)
- {
- Size ptrSize = r->dataLength + sizeof(ProtoRString);
- RStringPtr result = (RStringPtr) FAILNewPtr(ptrSize);
- BlockMove( r, result, ptrSize);
- return result;
- }
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, const LocalRecordID& l)
- {
- return s << "LocalRecordID: '" << l.recordName << "', '" << l.recordType << "' " << l.cid << flush;
- }
-
- /***********************************|****************************************/
-
- #if THINK_CPLUS
- ostream& operator << (ostream& s, const LocalRecordID* l)
- {
- if (l)
- return s << (LocalRecordID*) l;
- else
- return s << "localRID==nil ";
- }
- #endif
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, const ShortRecordID& l)
- {
- return s << "ShortRecordID: " << l.rli << " " << l.cid << flush;
- }
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, const ShortRecordID* l)
- {
- #ifndef THINK_CPLUS
- return s << *l;
- #else
- return s << "(ShortRecordID* unsupported) ";
- #endif
- }
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, const DSSpec& dsSpec)
- {
- s << *dsSpec.entitySpecifier << endl << flush;
- s << "xtnType="; s.write((char*) &dsSpec.extensionType, (int) sizeof(dsSpec.extensionType)); s << " len=" << dsSpec.extensionSize << flush;
- return s << " data='"; s.write((char*) dsSpec.extensionValue, (int) dsSpec.extensionSize); s << "'" << endl << flush;
- }
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, DSSpec* dsSpecPtr)
- {
- #ifndef THINK_CPLUS
- return s << *dsSpecPtr;
- #else
- return s << "(DSSpec* unsupported) ";
- #endif
- }
-
- /***********************************|****************************************/
-
- ostream& operator<< (ostream& s, const MailTime& time)
- {
- Str255 dateStr255, timeStr255;
- IUDateString (time.time + time.offset, shortDate, dateStr255);
- IUTimeString (time.time + time.offset, false, timeStr255);
- return s << dateStr255 << " " << timeStr255;
- }
-
- /***********************************|****************************************/
-
- ostream& operator << (ostream& s, const MailLetterID& id)
- {
- for (short i = 0; i < 8; ++i)
- s << id.id[i] << " ";
- return s << flush;
- }
-
- /***********************************|****************************************/
-
- Boolean IsAOCEInstalled ()
- {
- long value;
-
- return ( ( Gestalt ( gestaltOCEToolboxAttr, &value ) == noErr ) && ( value & gestaltOCETBPresent ) );
- }
-
- /***********************************|****************************************/
-
- Boolean IsAOCEAvailable ()
- {
- long value;
- return ( ( Gestalt ( gestaltOCEToolboxAttr, &value ) == noErr ) && ( value & gestaltOCETBAvailable ) );
- }
-
- /***********************************|****************************************/
-
- Boolean IsAOCEMailServerAvailable ()
- {
- long value;
- return ( ( Gestalt ( gestaltOCEToolboxAttr, &value ) == noErr ) && ( value & gestaltOCESFServerAvailable ) );
- }
-
- /***********************************|****************************************/
-